package cn.smbms.controller;


import cn.smbms.beans.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ Author   ：陈慧杰
 * @ Date     ：Created in 8:21 2021/12/1
 */
@Controller
public class IndexController extends AbstractController {
    @Override
    @RequestMapping("indexController")
    protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        System.out.println("测试");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("one");
        return modelAndView;
    }
    @RequestMapping("test01")
    public ModelAndView test01(@RequestParam String userName){
        System.out.println(userName);
        return new ModelAndView();
    }
    @RequestMapping(value = "test02" ,method = RequestMethod.GET ,params = "userName")
    public ModelAndView test02(String userName){
        System.out.println(userName);
        ModelAndView modelAndView = new ModelAndView();
        User user = new User();
        user.setUserName("userName");
        modelAndView.addObject(user);
        modelAndView.setViewName("two");
        return  modelAndView;
    }


}
